import {Config} from './config.js'

class Base {
  constructor() {
    "use strict";
    this.baseRestUrl = Config.apiUrl;
  }

  request(params) {
    var that = this;
    var url = that.baseRestUrl + params.url;
    if (!params.type) {
      params.type = 'get';
    }
    if (params.setUpUrl == false) {
      url = params.url
    }
    wx.request({
      url: url,
      data: params.data,
      method: params.type,
      header: {
        'content-type': 'application/json'
      },
      success(res) {
        var code = res.code;
        if (code == '0') {
          params.sCallback && params.sCallback(res.data)
        }
      },
      fail(err) {
        console.log(err);
      },
    });
  }
}

export {
  Base
};